<template>
  <div>
    <city-header></city-header>
    <city-search :citylist="cities"></city-search>
    <city-list :citylist="cities" :hot="hotCities" :apl="apl"></city-list>
    <city-alphabet :citylist="cities" @Alpchange="Alpchange"></city-alphabet>
  </div>
</template>

<script>
import axios from 'axios'
import CityHeader from './component/Header'
import CitySearch from './component/Search'
import CityList from './component/List'
import CityAlphabet from './component/Alphabet'
export default {
  name: 'city',
  components: {
    CityHeader,
    CitySearch,
    CityList,
    CityAlphabet
  },
  data () {
    return {
      cities: {},
      hotCities: [],
      apl: ''
    }
  },
  methods: {
    getCityInfo () {
      // axios.get('/api/city.json').then(this.getCityInfoSucc)

      axios.get('http://linhaoj.gitee.io/vue-travel/static/mock/city.json')
        .then(this.getCityInfoSucc)
    },
    getCityInfoSucc (res) {
      const resjson = res.data
      if (resjson.ret && resjson.data) {
        const datas = resjson.data
        this.cities = datas.cities
        this.hotCities = datas.hotCities
      }
    },
    Alpchange (res) {
      this.apl = res
    }
  },
  mounted () {
    this.getCityInfo()
  }
}
</script>

<style scoped>

</style>
